package com.dd.stack.kafka.common.pojo.BO;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.ZoneId;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/6/14 23:25
 * @Description 使用Json序列化User类
 */
@Data
public class JsonUserBO {
    private Long id;
    private String username;
    private String email;

    @JsonFormat(
            shape = JsonFormat.Shape.STRING,
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "UTC"  // 关键：强制使用 UTC 时区
    )
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createdAt;

    // 可选：添加原始时区信息（用于跨时区系统）
    private String originalTimezone = ZoneId.systemDefault().getId();
}
